package com.hong.aop;

import java.util.ArrayList;
import java.util.List;

public class Client {
    public static void main(String[] args) {
        /**
         * CGLib不支持嵌套增强
         */
       /* Object beforeProxy = new BeforeProxy().getProxy(GreetingImpl.class);
        Object afterBeforeProxy = new AfterProxy().getProxy(beforeProxy.getClass());
        GreetingImpl greeting = (GreetingImpl) afterBeforeProxy;
        greeting.sayHello("AOP");*/

        /**
         * 链式代理实现AOP嵌套增强
         */
        List<Proxy> proxyList = new ArrayList<>();
        proxyList.add(new BeforeProxy2());
        proxyList.add(new AfterProxy2());
        GreetingImpl greeting = ProxyManager.getInstance().createProxy(GreetingImpl.class, proxyList);
        greeting.sayHello("AOP");
    }
}
